local Achievement = class("Achievement")



function Achievement:read(value)
	self.uid = value.uid
	self.progress = value.progress
    if not self.progress then
        self.progress=0
    end
	self.state = value.state--// 0 - 未完成, 1 - 已完成, 2 - 已领取
	self.finishedTime = value.finishedTime-- 完成时间

	self.conf =  GD:getAchievementConfig(self.uid)
	self.timeType = self.conf and tonumber(self.conf.time) or nil
	self.showType = self.conf and tonumber(self.conf.showType) or nil
	-- print("Achievement:read  ********************* ")
	-- print("Achievement:read  self.uid = ",self.uid)
	-- print("Achievement:read  self.progress = ",self.progress)
	-- print("Achievement:read  self.state = ",self.state)
	-- print("Achievement:read  self.finishedTime = ",self.finishedTime)
end


function Achievement:write(value)
	value.uid = self.uid
	value.progress = self.progress
	value.state = self.state
	value.finishedTime = self.finishedTime
end

function Achievement:ctor()
	self.uid = 0
	self.progress = 0
	self.state = 0
	self.finishedTime = 0

	-- 配表中数据
	self.conf = nil
end

function Achievement:isComp()
	return self.state == 1
end

function Achievement:isReceived()
	return self.state == 2
end

function Achievement:hasReward()
	return self.state == 1
end

return Achievement
